package org.swizframework.autowire
{
	import org.flexunit.Assert;
	import org.swizframework.Swiz;

	public class AutowireTest
	{
		
		[Autowire(bean="primitiveString")]
		public var primitiveString:String;
		
		[Autowire(bean="barController")]
		public var barController:BarController;
		
		[Autowire]
		public var iBarController:IBarController;
		
		[Before]
		public function setUp():void
		{
			Swiz.getInstance().addBean("primitiveString", new String("hey dude"));
			var bc:IBarController = new BarController();
			Swiz.getInstance().addBean("barController", bc);
			Swiz.getInstance().autowire(this);
		}
		
		[Test(description="test autowire primitive String")]
		public function testAutowirePrimitiveBean():void
		{
			trace(primitiveString);
			Assert.assertNotNull("primitiveString still null. Autowire primitive bean does not work.", primitiveString)
		}
		
		[Test]
		public function testAutowireByName():void
		{
			Assert.assertNotNull("barController still null. AutowireByType does not work.", barController)
		}
		
		[Test]
		public function testAutowireByType():void
		{
			Assert.assertNotNull("iBarController still null. AutowireByType with interface does not work.", iBarController)
		}
		
	}
}

internal interface IBarController{}
internal class BarController implements IBarController{}